package com.cy.pj.web配置类和控制层.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.common.pojo.SysDept;
import com.cy.pj.service.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dept/")
public class SysDeptController {
    @Autowired
    private SysDeptService sysDeptService;

@GetMapping
    public JsonResult dofindObjedt(){
return new JsonResult(sysDeptService.findDeptsService());
}

@GetMapping("treeNodes")
public JsonResult doFindTreeNodes(){
    return new JsonResult(sysDeptService.findDeptTreeNodesService());
}

@PutMapping
public JsonResult doUpdateDept(@RequestBody SysDept sysDept){
    sysDeptService.updateDeptsService(sysDept);
return new JsonResult("更新成功");
}

@PostMapping
    public JsonResult doSaveDepts(@RequestBody SysDept sysDept){
    sysDeptService.insertDeptsService(sysDept);
    return new JsonResult("新增数据成功");
}

@GetMapping("{id}")
public JsonResult dofindById(@PathVariable Integer id){

    return new JsonResult(sysDeptService.findByIdService(id));
}

}
